package realQuestion.B;

public class Solution1 {


        /**
         * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
         *
         *
         * @param n long长整型
         * @return int整型
         */
        public int DoubleNumber (long n) {

            int count=0;
            // write code here

            for (int i = 0; i <=n; i++) {
                if (isDoubleNumber(i)) {
                    count++;
                }

            }

            return  count;
        }


        public  boolean isDoubleNumber(int num){
            String s = String.valueOf(num);
            int length = s.length();
            if (length%2!=0){
                return false;
            }

            for (int i = 0; i < length / 2; i++) {
                if (s.charAt(i)!=s.charAt(i+length/2)){
                    return  false;
                }
            }
            return  true;

        }

    }
